package com.example.webcrawlercoursedesign;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

/**
 * Created by Jawor
 * Time: 2018/5/28
 */

public class MyFragmentPagerAdapter extends FragmentPagerAdapter {

    private String[] mTitles = new String[]{"虎扑", "腾讯", "新浪","央视网"};

    public MyFragmentPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int position) {
        if (position == 1) {
            return new Fragment163();
        }
        else if (position == 0){
            return new FragmentHupu();
        }
        else if (position == 2){
            return new FragmentSina();
        }
        else if (position == 3){
            return new FragmentCCTV();
        }
        return new Fragment2();
    }

    @Override
    public int getCount() {
        return mTitles.length;
    }

    //ViewPager与TabLayout绑定后，这里获取到PageTitle就是Tab的Text
    @Override
    public CharSequence getPageTitle(int position) {
        return mTitles[position];
    }
}
